
kernel.elf：     文件格式 elf64-littleriscv


Disassembly of section .text:

0000000080000000 <_entry>:
.global _entry

# 内核入口点 - QEMU从这里开始执行
_entry:
    # 设置栈指针
    la sp, stack0           # 加载栈地址
    80000000:	00001117          	auipc	sp,0x1
    80000004:	ba010113          	add	sp,sp,-1120 # 80000ba0 <stack0>
    li t0, 4096             # 栈大小 4KB
    80000008:	6285                	lui	t0,0x1
    add sp, sp, t0          # 设置栈顶
    8000000a:	9116                	add	sp,sp,t0
    
    # 跳转到C主函数
    call main
    8000000c:	006000ef          	jal	80000012 <main>

0000000080000010 <spin>:
    
    # 如果main返回，进入死循环
spin:
    j spin
    80000010:	a001                	j	80000010 <spin>

0000000080000012 <main>:
#include "printf.h"

void main() {
    80000012:	1101                	add	sp,sp,-32
    80000014:	ec06                	sd	ra,24(sp)
    80000016:	e822                	sd	s0,16(sp)
    80000018:	1000                	add	s0,sp,32
    // 1. 首先显示一些内容
    puts("=== Initial Content (Before Clear) ===\n");
    8000001a:	00000517          	auipc	a0,0x0
    8000001e:	7be50513          	add	a0,a0,1982 # 800007d8 <test_printf_edge_cases+0x80>
    80000022:	52c000ef          	jal	8000054e <puts>
    printf("Line 1: Initial text\n");
    80000026:	00000517          	auipc	a0,0x0
    8000002a:	7da50513          	add	a0,a0,2010 # 80000800 <test_printf_edge_cases+0xa8>
    8000002e:	34c000ef          	jal	8000037a <printf>
    printf("Line 2: More content here\n");
    80000032:	00000517          	auipc	a0,0x0
    80000036:	7e650513          	add	a0,a0,2022 # 80000818 <test_printf_edge_cases+0xc0>
    8000003a:	340000ef          	jal	8000037a <printf>
    printf("Line 3: This will be cleared\n");
    8000003e:	00000517          	auipc	a0,0x0
    80000042:	7fa50513          	add	a0,a0,2042 # 80000838 <test_printf_edge_cases+0xe0>
    80000046:	334000ef          	jal	8000037a <printf>
    
    // 短暂延迟，让你能看到清屏前的效果
    for (volatile int i = 0; i < 1000000; i++);
    8000004a:	fe042623          	sw	zero,-20(s0)
    8000004e:	a801                	j	8000005e <main+0x4c>
    80000050:	fec42783          	lw	a5,-20(s0)
    80000054:	2781                	sext.w	a5,a5
    80000056:	2785                	addw	a5,a5,1
    80000058:	2781                	sext.w	a5,a5
    8000005a:	fef42623          	sw	a5,-20(s0)
    8000005e:	fec42783          	lw	a5,-20(s0)
    80000062:	2781                	sext.w	a5,a5
    80000064:	873e                	mv	a4,a5
    80000066:	000f47b7          	lui	a5,0xf4
    8000006a:	23f78793          	add	a5,a5,575 # f423f <_entry-0x7ff0bdc1>
    8000006e:	fee7d1e3          	bge	a5,a4,80000050 <main+0x3e>
    
    // 2. 清屏演示 - 核心功能
    clear_screen();
    80000072:	4fa000ef          	jal	8000056c <clear_screen>
    puts("=== After Clear Screen ===\n");
    80000076:	00000517          	auipc	a0,0x0
    8000007a:	7e250513          	add	a0,a0,2018 # 80000858 <test_printf_edge_cases+0x100>
    8000007e:	4d0000ef          	jal	8000054e <puts>
    printf("Screen cleared successfully!\n\n");
    80000082:	00000517          	auipc	a0,0x0
    80000086:	7f650513          	add	a0,a0,2038 # 80000878 <test_printf_edge_cases+0x120>
    8000008a:	2f0000ef          	jal	8000037a <printf>
    
    // 3. printf格式化输出演示 - 核心功能
    puts("=== printf Formatting Tests ===\n");
    8000008e:	00001517          	auipc	a0,0x1
    80000092:	80a50513          	add	a0,a0,-2038 # 80000898 <test_printf_edge_cases+0x140>
    80000096:	4b8000ef          	jal	8000054e <puts>
    
    printf("Integer: %d\n", 42);
    8000009a:	02a00593          	li	a1,42
    8000009e:	00001517          	auipc	a0,0x1
    800000a2:	82250513          	add	a0,a0,-2014 # 800008c0 <test_printf_edge_cases+0x168>
    800000a6:	2d4000ef          	jal	8000037a <printf>
    printf("Negative: %d\n", -123);
    800000aa:	f8500593          	li	a1,-123
    800000ae:	00001517          	auipc	a0,0x1
    800000b2:	82250513          	add	a0,a0,-2014 # 800008d0 <test_printf_edge_cases+0x178>
    800000b6:	2c4000ef          	jal	8000037a <printf>
    printf("Zero: %d\n", 0);
    800000ba:	4581                	li	a1,0
    800000bc:	00001517          	auipc	a0,0x1
    800000c0:	82450513          	add	a0,a0,-2012 # 800008e0 <test_printf_edge_cases+0x188>
    800000c4:	2b6000ef          	jal	8000037a <printf>
    printf("Hex: 0x%x\n", 0xABC);
    800000c8:	6785                	lui	a5,0x1
    800000ca:	abc78593          	add	a1,a5,-1348 # abc <_entry-0x7ffff544>
    800000ce:	00001517          	auipc	a0,0x1
    800000d2:	82250513          	add	a0,a0,-2014 # 800008f0 <test_printf_edge_cases+0x198>
    800000d6:	2a4000ef          	jal	8000037a <printf>
    printf("Char: %c\n", 'X');
    800000da:	05800593          	li	a1,88
    800000de:	00001517          	auipc	a0,0x1
    800000e2:	82250513          	add	a0,a0,-2014 # 80000900 <test_printf_edge_cases+0x1a8>
    800000e6:	294000ef          	jal	8000037a <printf>
    printf("String: %s\n", "Hello OS!");
    800000ea:	00001597          	auipc	a1,0x1
    800000ee:	82658593          	add	a1,a1,-2010 # 80000910 <test_printf_edge_cases+0x1b8>
    800000f2:	00001517          	auipc	a0,0x1
    800000f6:	82e50513          	add	a0,a0,-2002 # 80000920 <test_printf_edge_cases+0x1c8>
    800000fa:	280000ef          	jal	8000037a <printf>
    printf("Percent: 100%%\n\n");
    800000fe:	00001517          	auipc	a0,0x1
    80000102:	83250513          	add	a0,a0,-1998 # 80000930 <test_printf_edge_cases+0x1d8>
    80000106:	274000ef          	jal	8000037a <printf>
    
    // 4. 边界情况测试
    puts("=== Edge Cases ===\n");
    8000010a:	00001517          	auipc	a0,0x1
    8000010e:	83e50513          	add	a0,a0,-1986 # 80000948 <test_printf_edge_cases+0x1f0>
    80000112:	43c000ef          	jal	8000054e <puts>
    printf("INT_MAX: %d\n", 2147483647);
    80000116:	800007b7          	lui	a5,0x80000
    8000011a:	fff7c593          	not	a1,a5
    8000011e:	00001517          	auipc	a0,0x1
    80000122:	84250513          	add	a0,a0,-1982 # 80000960 <test_printf_edge_cases+0x208>
    80000126:	254000ef          	jal	8000037a <printf>
    printf("INT_MIN: %d\n", -2147483648);
    8000012a:	800005b7          	lui	a1,0x80000
    8000012e:	00001517          	auipc	a0,0x1
    80000132:	84250513          	add	a0,a0,-1982 # 80000970 <test_printf_edge_cases+0x218>
    80000136:	244000ef          	jal	8000037a <printf>
    printf("NULL: %s\n", (char*)0);
    8000013a:	4581                	li	a1,0
    8000013c:	00001517          	auipc	a0,0x1
    80000140:	84450513          	add	a0,a0,-1980 # 80000980 <test_printf_edge_cases+0x228>
    80000144:	236000ef          	jal	8000037a <printf>
    printf("Empty: %s\n", "");
    80000148:	00001597          	auipc	a1,0x1
    8000014c:	84858593          	add	a1,a1,-1976 # 80000990 <test_printf_edge_cases+0x238>
    80000150:	00001517          	auipc	a0,0x1
    80000154:	84850513          	add	a0,a0,-1976 # 80000998 <test_printf_edge_cases+0x240>
    80000158:	222000ef          	jal	8000037a <printf>
    
    // 5. 清屏功能二次演示
    puts("\n=== Second Clear Demo ===");
    8000015c:	00001517          	auipc	a0,0x1
    80000160:	84c50513          	add	a0,a0,-1972 # 800009a8 <test_printf_edge_cases+0x250>
    80000164:	3ea000ef          	jal	8000054e <puts>
    printf("Press any key in QEMU to see clear screen again...\n");
    80000168:	00001517          	auipc	a0,0x1
    8000016c:	86050513          	add	a0,a0,-1952 # 800009c8 <test_printf_edge_cases+0x270>
    80000170:	20a000ef          	jal	8000037a <printf>
    
    while (1) {
    80000174:	0001                	nop
    80000176:	bffd                	j	80000174 <main+0x162>

0000000080000178 <uart_init>:
#define REG(reg) ((volatile unsigned char *)(UART0 + reg))
#define THR 0
#define LSR 5
#define LSR_TX_READY (1 << 5)

void uart_init(void) {
    80000178:	1141                	add	sp,sp,-16
    8000017a:	e422                	sd	s0,8(sp)
    8000017c:	0800                	add	s0,sp,16
    // QEMU UART通常已初始化
}
    8000017e:	0001                	nop
    80000180:	6422                	ld	s0,8(sp)
    80000182:	0141                	add	sp,sp,16
    80000184:	8082                	ret

0000000080000186 <uart_putc>:

void uart_putc(char c) {
    80000186:	1101                	add	sp,sp,-32
    80000188:	ec22                	sd	s0,24(sp)
    8000018a:	1000                	add	s0,sp,32
    8000018c:	87aa                	mv	a5,a0
    8000018e:	fef407a3          	sb	a5,-17(s0)
    while ((*REG(LSR) & LSR_TX_READY) == 0);
    80000192:	0001                	nop
    80000194:	100007b7          	lui	a5,0x10000
    80000198:	0795                	add	a5,a5,5 # 10000005 <_entry-0x6ffffffb>
    8000019a:	0007c783          	lbu	a5,0(a5)
    8000019e:	0ff7f793          	zext.b	a5,a5
    800001a2:	2781                	sext.w	a5,a5
    800001a4:	0207f793          	and	a5,a5,32
    800001a8:	2781                	sext.w	a5,a5
    800001aa:	d7ed                	beqz	a5,80000194 <uart_putc+0xe>
    *REG(THR) = c;
    800001ac:	100007b7          	lui	a5,0x10000
    800001b0:	fef44703          	lbu	a4,-17(s0)
    800001b4:	00e78023          	sb	a4,0(a5) # 10000000 <_entry-0x70000000>
}
    800001b8:	0001                	nop
    800001ba:	6462                	ld	s0,24(sp)
    800001bc:	6105                	add	sp,sp,32
    800001be:	8082                	ret

00000000800001c0 <uart_puts>:

void uart_puts(const char *s) {
    800001c0:	1101                	add	sp,sp,-32
    800001c2:	ec06                	sd	ra,24(sp)
    800001c4:	e822                	sd	s0,16(sp)
    800001c6:	1000                	add	s0,sp,32
    800001c8:	fea43423          	sd	a0,-24(s0)
    while (*s) {
    800001cc:	a821                	j	800001e4 <uart_puts+0x24>
        uart_putc(*s++);
    800001ce:	fe843783          	ld	a5,-24(s0)
    800001d2:	00178713          	add	a4,a5,1
    800001d6:	fee43423          	sd	a4,-24(s0)
    800001da:	0007c783          	lbu	a5,0(a5)
    800001de:	853e                	mv	a0,a5
    800001e0:	fa7ff0ef          	jal	80000186 <uart_putc>
    while (*s) {
    800001e4:	fe843783          	ld	a5,-24(s0)
    800001e8:	0007c783          	lbu	a5,0(a5)
    800001ec:	f3ed                	bnez	a5,800001ce <uart_puts+0xe>
    }
    800001ee:	0001                	nop
    800001f0:	0001                	nop
    800001f2:	60e2                	ld	ra,24(sp)
    800001f4:	6442                	ld	s0,16(sp)
    800001f6:	6105                	add	sp,sp,32
    800001f8:	8082                	ret

00000000800001fa <printint>:

extern void uart_putc(char c);
extern void uart_puts(const char *s);

// 数字转换函数
static void printint(int num, int base, int sign) {
    800001fa:	715d                	add	sp,sp,-80
    800001fc:	e486                	sd	ra,72(sp)
    800001fe:	e0a2                	sd	s0,64(sp)
    80000200:	0880                	add	s0,sp,80
    80000202:	87aa                	mv	a5,a0
    80000204:	86ae                	mv	a3,a1
    80000206:	8732                	mv	a4,a2
    80000208:	faf42e23          	sw	a5,-68(s0)
    8000020c:	87b6                	mv	a5,a3
    8000020e:	faf42c23          	sw	a5,-72(s0)
    80000212:	87ba                	mv	a5,a4
    80000214:	faf42a23          	sw	a5,-76(s0)
    char buf[32];
    int i = 0;
    80000218:	fe042623          	sw	zero,-20(s0)
    unsigned int x;

    if (sign && num < 0) {
    8000021c:	fb442783          	lw	a5,-76(s0)
    80000220:	2781                	sext.w	a5,a5
    80000222:	cf91                	beqz	a5,8000023e <printint+0x44>
    80000224:	fbc42783          	lw	a5,-68(s0)
    80000228:	2781                	sext.w	a5,a5
    8000022a:	0007da63          	bgez	a5,8000023e <printint+0x44>
        x = -num;
    8000022e:	fbc42783          	lw	a5,-68(s0)
    80000232:	40f007bb          	negw	a5,a5
    80000236:	2781                	sext.w	a5,a5
    80000238:	fef42423          	sw	a5,-24(s0)
    8000023c:	a029                	j	80000246 <printint+0x4c>
    } else {
        x = num;
    8000023e:	fbc42783          	lw	a5,-68(s0)
    80000242:	fef42423          	sw	a5,-24(s0)
    }

    do {
        int digit = x % base;
    80000246:	fb842783          	lw	a5,-72(s0)
    8000024a:	fe842703          	lw	a4,-24(s0)
    8000024e:	02f777bb          	remuw	a5,a4,a5
    80000252:	2781                	sext.w	a5,a5
    80000254:	fef42223          	sw	a5,-28(s0)
        // 直接计算字符，避免字符串数组
        if (digit < 10) {
    80000258:	fe442783          	lw	a5,-28(s0)
    8000025c:	0007871b          	sext.w	a4,a5
    80000260:	47a5                	li	a5,9
    80000262:	02e7c563          	blt	a5,a4,8000028c <printint+0x92>
            buf[i++] = '0' + digit;
    80000266:	fe442783          	lw	a5,-28(s0)
    8000026a:	0ff7f713          	zext.b	a4,a5
    8000026e:	fec42783          	lw	a5,-20(s0)
    80000272:	0017869b          	addw	a3,a5,1
    80000276:	fed42623          	sw	a3,-20(s0)
    8000027a:	0307071b          	addw	a4,a4,48
    8000027e:	0ff77713          	zext.b	a4,a4
    80000282:	17c1                	add	a5,a5,-16
    80000284:	97a2                	add	a5,a5,s0
    80000286:	fce78823          	sb	a4,-48(a5)
    8000028a:	a01d                	j	800002b0 <printint+0xb6>
        } else {
            buf[i++] = 'a' + (digit - 10);
    8000028c:	fe442783          	lw	a5,-28(s0)
    80000290:	0ff7f713          	zext.b	a4,a5
    80000294:	fec42783          	lw	a5,-20(s0)
    80000298:	0017869b          	addw	a3,a5,1
    8000029c:	fed42623          	sw	a3,-20(s0)
    800002a0:	0577071b          	addw	a4,a4,87
    800002a4:	0ff77713          	zext.b	a4,a4
    800002a8:	17c1                	add	a5,a5,-16
    800002aa:	97a2                	add	a5,a5,s0
    800002ac:	fce78823          	sb	a4,-48(a5)
        }
        x /= base;
    800002b0:	fb842783          	lw	a5,-72(s0)
    800002b4:	fe842703          	lw	a4,-24(s0)
    800002b8:	02f757bb          	divuw	a5,a4,a5
    800002bc:	fef42423          	sw	a5,-24(s0)
    } while (x != 0);
    800002c0:	fe842783          	lw	a5,-24(s0)
    800002c4:	2781                	sext.w	a5,a5
    800002c6:	f3c1                	bnez	a5,80000246 <printint+0x4c>

    if (sign && num < 0) {
    800002c8:	fb442783          	lw	a5,-76(s0)
    800002cc:	2781                	sext.w	a5,a5
    800002ce:	cf85                	beqz	a5,80000306 <printint+0x10c>
    800002d0:	fbc42783          	lw	a5,-68(s0)
    800002d4:	2781                	sext.w	a5,a5
    800002d6:	0207d863          	bgez	a5,80000306 <printint+0x10c>
        buf[i++] = '-';
    800002da:	fec42783          	lw	a5,-20(s0)
    800002de:	0017871b          	addw	a4,a5,1
    800002e2:	fee42623          	sw	a4,-20(s0)
    800002e6:	17c1                	add	a5,a5,-16
    800002e8:	97a2                	add	a5,a5,s0
    800002ea:	02d00713          	li	a4,45
    800002ee:	fce78823          	sb	a4,-48(a5)
    }

    while (--i >= 0) {
    800002f2:	a811                	j	80000306 <printint+0x10c>
        uart_putc(buf[i]);
    800002f4:	fec42783          	lw	a5,-20(s0)
    800002f8:	17c1                	add	a5,a5,-16
    800002fa:	97a2                	add	a5,a5,s0
    800002fc:	fd07c783          	lbu	a5,-48(a5)
    80000300:	853e                	mv	a0,a5
    80000302:	e85ff0ef          	jal	80000186 <uart_putc>
    while (--i >= 0) {
    80000306:	fec42783          	lw	a5,-20(s0)
    8000030a:	37fd                	addw	a5,a5,-1
    8000030c:	fef42623          	sw	a5,-20(s0)
    80000310:	fec42783          	lw	a5,-20(s0)
    80000314:	2781                	sext.w	a5,a5
    80000316:	fc07dfe3          	bgez	a5,800002f4 <printint+0xfa>
    }
}
    8000031a:	0001                	nop
    8000031c:	0001                	nop
    8000031e:	60a6                	ld	ra,72(sp)
    80000320:	6406                	ld	s0,64(sp)
    80000322:	6161                	add	sp,sp,80
    80000324:	8082                	ret

0000000080000326 <printstring>:

// 字符串输出
static void printstring(const char *str) {
    80000326:	7179                	add	sp,sp,-48
    80000328:	f406                	sd	ra,40(sp)
    8000032a:	f022                	sd	s0,32(sp)
    8000032c:	1800                	add	s0,sp,48
    8000032e:	fca43c23          	sd	a0,-40(s0)
    if (str == 0) {
    80000332:	fd843783          	ld	a5,-40(s0)
    80000336:	eb81                	bnez	a5,80000346 <printstring+0x20>
        uart_puts("(null)");
    80000338:	00000517          	auipc	a0,0x0
    8000033c:	6c850513          	add	a0,a0,1736 # 80000a00 <test_printf_edge_cases+0x2a8>
    80000340:	e81ff0ef          	jal	800001c0 <uart_puts>
        return;
    80000344:	a03d                	j	80000372 <printstring+0x4c>
    }
    
    const char *p = str;
    80000346:	fd843783          	ld	a5,-40(s0)
    8000034a:	fef43423          	sd	a5,-24(s0)
    while (*p) {
    8000034e:	a829                	j	80000368 <printstring+0x42>
        uart_putc(*p);
    80000350:	fe843783          	ld	a5,-24(s0)
    80000354:	0007c783          	lbu	a5,0(a5)
    80000358:	853e                	mv	a0,a5
    8000035a:	e2dff0ef          	jal	80000186 <uart_putc>
        p++;
    8000035e:	fe843783          	ld	a5,-24(s0)
    80000362:	0785                	add	a5,a5,1
    80000364:	fef43423          	sd	a5,-24(s0)
    while (*p) {
    80000368:	fe843783          	ld	a5,-24(s0)
    8000036c:	0007c783          	lbu	a5,0(a5)
    80000370:	f3e5                	bnez	a5,80000350 <printstring+0x2a>
    }
}
    80000372:	70a2                	ld	ra,40(sp)
    80000374:	7402                	ld	s0,32(sp)
    80000376:	6145                	add	sp,sp,48
    80000378:	8082                	ret

000000008000037a <printf>:

// 主printf函数
int printf(const char *fmt, ...) {
    8000037a:	7159                	add	sp,sp,-112
    8000037c:	f406                	sd	ra,40(sp)
    8000037e:	f022                	sd	s0,32(sp)
    80000380:	1800                	add	s0,sp,48
    80000382:	fca43c23          	sd	a0,-40(s0)
    80000386:	e40c                	sd	a1,8(s0)
    80000388:	e810                	sd	a2,16(s0)
    8000038a:	ec14                	sd	a3,24(s0)
    8000038c:	f018                	sd	a4,32(s0)
    8000038e:	f41c                	sd	a5,40(s0)
    80000390:	03043823          	sd	a6,48(s0)
    80000394:	03143c23          	sd	a7,56(s0)
    va_list ap;
    va_start(ap, fmt);
    80000398:	04040793          	add	a5,s0,64
    8000039c:	fcf43823          	sd	a5,-48(s0)
    800003a0:	fd043783          	ld	a5,-48(s0)
    800003a4:	fc878793          	add	a5,a5,-56
    800003a8:	fef43023          	sd	a5,-32(s0)

    int i;
    char c;
    for (i = 0; (c = fmt[i]) != '\0'; i++) {
    800003ac:	fe042623          	sw	zero,-20(s0)
    800003b0:	a2b9                	j	800004fe <printf+0x184>
        if (c != '%') {
    800003b2:	feb44783          	lbu	a5,-21(s0)
    800003b6:	0ff7f713          	zext.b	a4,a5
    800003ba:	02500793          	li	a5,37
    800003be:	00f70863          	beq	a4,a5,800003ce <printf+0x54>
            uart_putc(c);
    800003c2:	feb44783          	lbu	a5,-21(s0)
    800003c6:	853e                	mv	a0,a5
    800003c8:	dbfff0ef          	jal	80000186 <uart_putc>
            continue;
    800003cc:	a225                	j	800004f4 <printf+0x17a>
        }
        
        i++;
    800003ce:	fec42783          	lw	a5,-20(s0)
    800003d2:	2785                	addw	a5,a5,1
    800003d4:	fef42623          	sw	a5,-20(s0)
        c = fmt[i];
    800003d8:	fec42783          	lw	a5,-20(s0)
    800003dc:	fd843703          	ld	a4,-40(s0)
    800003e0:	97ba                	add	a5,a5,a4
    800003e2:	0007c783          	lbu	a5,0(a5)
    800003e6:	fef405a3          	sb	a5,-21(s0)
        if (c == '\0') break;
    800003ea:	feb44783          	lbu	a5,-21(s0)
    800003ee:	0ff7f793          	zext.b	a5,a5
    800003f2:	12078663          	beqz	a5,8000051e <printf+0x1a4>
        
        switch (c) {
    800003f6:	feb44783          	lbu	a5,-21(s0)
    800003fa:	2781                	sext.w	a5,a5
    800003fc:	86be                	mv	a3,a5
    800003fe:	02500713          	li	a4,37
    80000402:	0ce68a63          	beq	a3,a4,800004d6 <printf+0x15c>
    80000406:	86be                	mv	a3,a5
    80000408:	02500713          	li	a4,37
    8000040c:	0ce6ca63          	blt	a3,a4,800004e0 <printf+0x166>
    80000410:	86be                	mv	a3,a5
    80000412:	07800713          	li	a4,120
    80000416:	0cd74563          	blt	a4,a3,800004e0 <printf+0x166>
    8000041a:	86be                	mv	a3,a5
    8000041c:	06300713          	li	a4,99
    80000420:	0ce6c063          	blt	a3,a4,800004e0 <printf+0x166>
    80000424:	f9d7869b          	addw	a3,a5,-99
    80000428:	0006871b          	sext.w	a4,a3
    8000042c:	47d5                	li	a5,21
    8000042e:	0ae7e963          	bltu	a5,a4,800004e0 <printf+0x166>
    80000432:	02069793          	sll	a5,a3,0x20
    80000436:	9381                	srl	a5,a5,0x20
    80000438:	00279713          	sll	a4,a5,0x2
    8000043c:	00000797          	auipc	a5,0x0
    80000440:	5cc78793          	add	a5,a5,1484 # 80000a08 <test_printf_edge_cases+0x2b0>
    80000444:	97ba                	add	a5,a5,a4
    80000446:	439c                	lw	a5,0(a5)
    80000448:	0007871b          	sext.w	a4,a5
    8000044c:	00000797          	auipc	a5,0x0
    80000450:	5bc78793          	add	a5,a5,1468 # 80000a08 <test_printf_edge_cases+0x2b0>
    80000454:	97ba                	add	a5,a5,a4
    80000456:	8782                	jr	a5
            case 'd':
                printint(va_arg(ap, int), 10, 1);
    80000458:	fe043783          	ld	a5,-32(s0)
    8000045c:	00878713          	add	a4,a5,8
    80000460:	fee43023          	sd	a4,-32(s0)
    80000464:	439c                	lw	a5,0(a5)
    80000466:	4605                	li	a2,1
    80000468:	45a9                	li	a1,10
    8000046a:	853e                	mv	a0,a5
    8000046c:	d8fff0ef          	jal	800001fa <printint>
                break;
    80000470:	a051                	j	800004f4 <printf+0x17a>
            case 'u':
                printint(va_arg(ap, int), 10, 0);
    80000472:	fe043783          	ld	a5,-32(s0)
    80000476:	00878713          	add	a4,a5,8
    8000047a:	fee43023          	sd	a4,-32(s0)
    8000047e:	439c                	lw	a5,0(a5)
    80000480:	4601                	li	a2,0
    80000482:	45a9                	li	a1,10
    80000484:	853e                	mv	a0,a5
    80000486:	d75ff0ef          	jal	800001fa <printint>
                break;
    8000048a:	a0ad                	j	800004f4 <printf+0x17a>
            case 'x':
                printint(va_arg(ap, int), 16, 0);
    8000048c:	fe043783          	ld	a5,-32(s0)
    80000490:	00878713          	add	a4,a5,8
    80000494:	fee43023          	sd	a4,-32(s0)
    80000498:	439c                	lw	a5,0(a5)
    8000049a:	4601                	li	a2,0
    8000049c:	45c1                	li	a1,16
    8000049e:	853e                	mv	a0,a5
    800004a0:	d5bff0ef          	jal	800001fa <printint>
                break;
    800004a4:	a881                	j	800004f4 <printf+0x17a>
            case 'c':
                uart_putc((char)va_arg(ap, int));
    800004a6:	fe043783          	ld	a5,-32(s0)
    800004aa:	00878713          	add	a4,a5,8
    800004ae:	fee43023          	sd	a4,-32(s0)
    800004b2:	439c                	lw	a5,0(a5)
    800004b4:	0ff7f793          	zext.b	a5,a5
    800004b8:	853e                	mv	a0,a5
    800004ba:	ccdff0ef          	jal	80000186 <uart_putc>
                break;
    800004be:	a81d                	j	800004f4 <printf+0x17a>
            case 's':
                printstring(va_arg(ap, char*));
    800004c0:	fe043783          	ld	a5,-32(s0)
    800004c4:	00878713          	add	a4,a5,8
    800004c8:	fee43023          	sd	a4,-32(s0)
    800004cc:	639c                	ld	a5,0(a5)
    800004ce:	853e                	mv	a0,a5
    800004d0:	e57ff0ef          	jal	80000326 <printstring>
                break;
    800004d4:	a005                	j	800004f4 <printf+0x17a>
            case '%':
                uart_putc('%');
    800004d6:	02500513          	li	a0,37
    800004da:	cadff0ef          	jal	80000186 <uart_putc>
                break;
    800004de:	a819                	j	800004f4 <printf+0x17a>
            default:
                uart_putc('%');
    800004e0:	02500513          	li	a0,37
    800004e4:	ca3ff0ef          	jal	80000186 <uart_putc>
                uart_putc(c);
    800004e8:	feb44783          	lbu	a5,-21(s0)
    800004ec:	853e                	mv	a0,a5
    800004ee:	c99ff0ef          	jal	80000186 <uart_putc>
                break;
    800004f2:	0001                	nop
    for (i = 0; (c = fmt[i]) != '\0'; i++) {
    800004f4:	fec42783          	lw	a5,-20(s0)
    800004f8:	2785                	addw	a5,a5,1
    800004fa:	fef42623          	sw	a5,-20(s0)
    800004fe:	fec42783          	lw	a5,-20(s0)
    80000502:	fd843703          	ld	a4,-40(s0)
    80000506:	97ba                	add	a5,a5,a4
    80000508:	0007c783          	lbu	a5,0(a5)
    8000050c:	fef405a3          	sb	a5,-21(s0)
    80000510:	feb44783          	lbu	a5,-21(s0)
    80000514:	0ff7f793          	zext.b	a5,a5
    80000518:	e8079de3          	bnez	a5,800003b2 <printf+0x38>
    8000051c:	a011                	j	80000520 <printf+0x1a6>
        if (c == '\0') break;
    8000051e:	0001                	nop
        }
    }

    va_end(ap);
    return 0;
    80000520:	4781                	li	a5,0
}
    80000522:	853e                	mv	a0,a5
    80000524:	70a2                	ld	ra,40(sp)
    80000526:	7402                	ld	s0,32(sp)
    80000528:	6165                	add	sp,sp,112
    8000052a:	8082                	ret

000000008000052c <putc>:

// 基础输出函数
void putc(char c) {
    8000052c:	1101                	add	sp,sp,-32
    8000052e:	ec06                	sd	ra,24(sp)
    80000530:	e822                	sd	s0,16(sp)
    80000532:	1000                	add	s0,sp,32
    80000534:	87aa                	mv	a5,a0
    80000536:	fef407a3          	sb	a5,-17(s0)
    uart_putc(c);
    8000053a:	fef44783          	lbu	a5,-17(s0)
    8000053e:	853e                	mv	a0,a5
    80000540:	c47ff0ef          	jal	80000186 <uart_putc>
}
    80000544:	0001                	nop
    80000546:	60e2                	ld	ra,24(sp)
    80000548:	6442                	ld	s0,16(sp)
    8000054a:	6105                	add	sp,sp,32
    8000054c:	8082                	ret

000000008000054e <puts>:

void puts(const char *s) {
    8000054e:	1101                	add	sp,sp,-32
    80000550:	ec06                	sd	ra,24(sp)
    80000552:	e822                	sd	s0,16(sp)
    80000554:	1000                	add	s0,sp,32
    80000556:	fea43423          	sd	a0,-24(s0)
    uart_puts(s);
    8000055a:	fe843503          	ld	a0,-24(s0)
    8000055e:	c63ff0ef          	jal	800001c0 <uart_puts>
}
    80000562:	0001                	nop
    80000564:	60e2                	ld	ra,24(sp)
    80000566:	6442                	ld	s0,16(sp)
    80000568:	6105                	add	sp,sp,32
    8000056a:	8082                	ret

000000008000056c <clear_screen>:

// 清屏功能
void clear_screen(void) {
    8000056c:	1141                	add	sp,sp,-16
    8000056e:	e406                	sd	ra,8(sp)
    80000570:	e022                	sd	s0,0(sp)
    80000572:	0800                	add	s0,sp,16
    uart_putc(0x1B); uart_putc('['); uart_putc('2'); uart_putc('J');
    80000574:	456d                	li	a0,27
    80000576:	c11ff0ef          	jal	80000186 <uart_putc>
    8000057a:	05b00513          	li	a0,91
    8000057e:	c09ff0ef          	jal	80000186 <uart_putc>
    80000582:	03200513          	li	a0,50
    80000586:	c01ff0ef          	jal	80000186 <uart_putc>
    8000058a:	04a00513          	li	a0,74
    8000058e:	bf9ff0ef          	jal	80000186 <uart_putc>
    uart_putc(0x1B); uart_putc('['); uart_putc('H');
    80000592:	456d                	li	a0,27
    80000594:	bf3ff0ef          	jal	80000186 <uart_putc>
    80000598:	05b00513          	li	a0,91
    8000059c:	bebff0ef          	jal	80000186 <uart_putc>
    800005a0:	04800513          	li	a0,72
    800005a4:	be3ff0ef          	jal	80000186 <uart_putc>
}
    800005a8:	0001                	nop
    800005aa:	60a2                	ld	ra,8(sp)
    800005ac:	6402                	ld	s0,0(sp)
    800005ae:	0141                	add	sp,sp,16
    800005b0:	8082                	ret

00000000800005b2 <goto_xy>:

// 光标定位
void goto_xy(int x, int y) {
    800005b2:	7179                	add	sp,sp,-48
    800005b4:	f406                	sd	ra,40(sp)
    800005b6:	f022                	sd	s0,32(sp)
    800005b8:	1800                	add	s0,sp,48
    800005ba:	87aa                	mv	a5,a0
    800005bc:	872e                	mv	a4,a1
    800005be:	fcf42e23          	sw	a5,-36(s0)
    800005c2:	87ba                	mv	a5,a4
    800005c4:	fcf42c23          	sw	a5,-40(s0)
    uart_putc(0x1B); uart_putc('[');
    800005c8:	456d                	li	a0,27
    800005ca:	bbdff0ef          	jal	80000186 <uart_putc>
    800005ce:	05b00513          	li	a0,91
    800005d2:	bb5ff0ef          	jal	80000186 <uart_putc>
    
    int n = y + 1;
    800005d6:	fd842783          	lw	a5,-40(s0)
    800005da:	2785                	addw	a5,a5,1
    800005dc:	fef42623          	sw	a5,-20(s0)
    if (n >= 10) uart_putc('0' + n / 10);
    800005e0:	fec42783          	lw	a5,-20(s0)
    800005e4:	0007871b          	sext.w	a4,a5
    800005e8:	47a5                	li	a5,9
    800005ea:	02e7d263          	bge	a5,a4,8000060e <goto_xy+0x5c>
    800005ee:	fec42783          	lw	a5,-20(s0)
    800005f2:	873e                	mv	a4,a5
    800005f4:	47a9                	li	a5,10
    800005f6:	02f747bb          	divw	a5,a4,a5
    800005fa:	2781                	sext.w	a5,a5
    800005fc:	0ff7f793          	zext.b	a5,a5
    80000600:	0307879b          	addw	a5,a5,48
    80000604:	0ff7f793          	zext.b	a5,a5
    80000608:	853e                	mv	a0,a5
    8000060a:	b7dff0ef          	jal	80000186 <uart_putc>
    uart_putc('0' + n % 10);
    8000060e:	fec42783          	lw	a5,-20(s0)
    80000612:	873e                	mv	a4,a5
    80000614:	47a9                	li	a5,10
    80000616:	02f767bb          	remw	a5,a4,a5
    8000061a:	2781                	sext.w	a5,a5
    8000061c:	0ff7f793          	zext.b	a5,a5
    80000620:	0307879b          	addw	a5,a5,48
    80000624:	0ff7f793          	zext.b	a5,a5
    80000628:	853e                	mv	a0,a5
    8000062a:	b5dff0ef          	jal	80000186 <uart_putc>
    uart_putc(';');
    8000062e:	03b00513          	li	a0,59
    80000632:	b55ff0ef          	jal	80000186 <uart_putc>
    
    n = x + 1;
    80000636:	fdc42783          	lw	a5,-36(s0)
    8000063a:	2785                	addw	a5,a5,1
    8000063c:	fef42623          	sw	a5,-20(s0)
    if (n >= 10) uart_putc('0' + n / 10);
    80000640:	fec42783          	lw	a5,-20(s0)
    80000644:	0007871b          	sext.w	a4,a5
    80000648:	47a5                	li	a5,9
    8000064a:	02e7d263          	bge	a5,a4,8000066e <goto_xy+0xbc>
    8000064e:	fec42783          	lw	a5,-20(s0)
    80000652:	873e                	mv	a4,a5
    80000654:	47a9                	li	a5,10
    80000656:	02f747bb          	divw	a5,a4,a5
    8000065a:	2781                	sext.w	a5,a5
    8000065c:	0ff7f793          	zext.b	a5,a5
    80000660:	0307879b          	addw	a5,a5,48
    80000664:	0ff7f793          	zext.b	a5,a5
    80000668:	853e                	mv	a0,a5
    8000066a:	b1dff0ef          	jal	80000186 <uart_putc>
    uart_putc('0' + n % 10);
    8000066e:	fec42783          	lw	a5,-20(s0)
    80000672:	873e                	mv	a4,a5
    80000674:	47a9                	li	a5,10
    80000676:	02f767bb          	remw	a5,a4,a5
    8000067a:	2781                	sext.w	a5,a5
    8000067c:	0ff7f793          	zext.b	a5,a5
    80000680:	0307879b          	addw	a5,a5,48
    80000684:	0ff7f793          	zext.b	a5,a5
    80000688:	853e                	mv	a0,a5
    8000068a:	afdff0ef          	jal	80000186 <uart_putc>
    uart_putc('H');
    8000068e:	04800513          	li	a0,72
    80000692:	af5ff0ef          	jal	80000186 <uart_putc>
}
    80000696:	0001                	nop
    80000698:	70a2                	ld	ra,40(sp)
    8000069a:	7402                	ld	s0,32(sp)
    8000069c:	6145                	add	sp,sp,48
    8000069e:	8082                	ret

00000000800006a0 <clear_line>:

// 清除当前行
void clear_line(void) {
    800006a0:	1141                	add	sp,sp,-16
    800006a2:	e406                	sd	ra,8(sp)
    800006a4:	e022                	sd	s0,0(sp)
    800006a6:	0800                	add	s0,sp,16
    uart_putc(0x1B); uart_putc('['); uart_putc('K');
    800006a8:	456d                	li	a0,27
    800006aa:	addff0ef          	jal	80000186 <uart_putc>
    800006ae:	05b00513          	li	a0,91
    800006b2:	ad5ff0ef          	jal	80000186 <uart_putc>
    800006b6:	04b00513          	li	a0,75
    800006ba:	acdff0ef          	jal	80000186 <uart_putc>
}
    800006be:	0001                	nop
    800006c0:	60a2                	ld	ra,8(sp)
    800006c2:	6402                	ld	s0,0(sp)
    800006c4:	0141                	add	sp,sp,16
    800006c6:	8082                	ret

00000000800006c8 <test_printf_basic>:

// 基础测试
void test_printf_basic(void) {
    800006c8:	1141                	add	sp,sp,-16
    800006ca:	e406                	sd	ra,8(sp)
    800006cc:	e022                	sd	s0,0(sp)
    800006ce:	0800                	add	s0,sp,16
    puts("=== Basic Format Tests ===\n");
    800006d0:	00000517          	auipc	a0,0x0
    800006d4:	39050513          	add	a0,a0,912 # 80000a60 <test_printf_edge_cases+0x308>
    800006d8:	e77ff0ef          	jal	8000054e <puts>
    printf("Decimal: %d\n", 42);
    800006dc:	02a00593          	li	a1,42
    800006e0:	00000517          	auipc	a0,0x0
    800006e4:	3a050513          	add	a0,a0,928 # 80000a80 <test_printf_edge_cases+0x328>
    800006e8:	c93ff0ef          	jal	8000037a <printf>
    printf("Negative: %d\n", -123);
    800006ec:	f8500593          	li	a1,-123
    800006f0:	00000517          	auipc	a0,0x0
    800006f4:	3a050513          	add	a0,a0,928 # 80000a90 <test_printf_edge_cases+0x338>
    800006f8:	c83ff0ef          	jal	8000037a <printf>
    printf("Unsigned: %u\n", 123);
    800006fc:	07b00593          	li	a1,123
    80000700:	00000517          	auipc	a0,0x0
    80000704:	3a050513          	add	a0,a0,928 # 80000aa0 <test_printf_edge_cases+0x348>
    80000708:	c73ff0ef          	jal	8000037a <printf>
    printf("Hexadecimal: 0x%x\n", 0xABC);
    8000070c:	6785                	lui	a5,0x1
    8000070e:	abc78593          	add	a1,a5,-1348 # abc <_entry-0x7ffff544>
    80000712:	00000517          	auipc	a0,0x0
    80000716:	39e50513          	add	a0,a0,926 # 80000ab0 <test_printf_edge_cases+0x358>
    8000071a:	c61ff0ef          	jal	8000037a <printf>
    printf("Character: %c\n", 'X');
    8000071e:	05800593          	li	a1,88
    80000722:	00000517          	auipc	a0,0x0
    80000726:	3a650513          	add	a0,a0,934 # 80000ac8 <test_printf_edge_cases+0x370>
    8000072a:	c51ff0ef          	jal	8000037a <printf>
    printf("String: %s\n", "Hello World");
    8000072e:	00000597          	auipc	a1,0x0
    80000732:	3aa58593          	add	a1,a1,938 # 80000ad8 <test_printf_edge_cases+0x380>
    80000736:	00000517          	auipc	a0,0x0
    8000073a:	3b250513          	add	a0,a0,946 # 80000ae8 <test_printf_edge_cases+0x390>
    8000073e:	c3dff0ef          	jal	8000037a <printf>
    printf("Percent: %%\n");
    80000742:	00000517          	auipc	a0,0x0
    80000746:	3b650513          	add	a0,a0,950 # 80000af8 <test_printf_edge_cases+0x3a0>
    8000074a:	c31ff0ef          	jal	8000037a <printf>
}
    8000074e:	0001                	nop
    80000750:	60a2                	ld	ra,8(sp)
    80000752:	6402                	ld	s0,0(sp)
    80000754:	0141                	add	sp,sp,16
    80000756:	8082                	ret

0000000080000758 <test_printf_edge_cases>:

// 边界情况测试
void test_printf_edge_cases(void) {
    80000758:	1141                	add	sp,sp,-16
    8000075a:	e406                	sd	ra,8(sp)
    8000075c:	e022                	sd	s0,0(sp)
    8000075e:	0800                	add	s0,sp,16
    puts("=== Edge Case Tests ===\n");
    80000760:	00000517          	auipc	a0,0x0
    80000764:	3a850513          	add	a0,a0,936 # 80000b08 <test_printf_edge_cases+0x3b0>
    80000768:	de7ff0ef          	jal	8000054e <puts>
    printf("INT_MAX: %d\n", 2147483647);
    8000076c:	800007b7          	lui	a5,0x80000
    80000770:	fff7c593          	not	a1,a5
    80000774:	00000517          	auipc	a0,0x0
    80000778:	3b450513          	add	a0,a0,948 # 80000b28 <test_printf_edge_cases+0x3d0>
    8000077c:	bffff0ef          	jal	8000037a <printf>
    printf("INT_MIN: %d\n", -2147483648);
    80000780:	800005b7          	lui	a1,0x80000
    80000784:	00000517          	auipc	a0,0x0
    80000788:	3b450513          	add	a0,a0,948 # 80000b38 <test_printf_edge_cases+0x3e0>
    8000078c:	befff0ef          	jal	8000037a <printf>
    printf("Zero: %d\n", 0);
    80000790:	4581                	li	a1,0
    80000792:	00000517          	auipc	a0,0x0
    80000796:	3b650513          	add	a0,a0,950 # 80000b48 <test_printf_edge_cases+0x3f0>
    8000079a:	be1ff0ef          	jal	8000037a <printf>
    printf("NULL string: %s\n", (char*)0);
    8000079e:	4581                	li	a1,0
    800007a0:	00000517          	auipc	a0,0x0
    800007a4:	3b850513          	add	a0,a0,952 # 80000b58 <test_printf_edge_cases+0x400>
    800007a8:	bd3ff0ef          	jal	8000037a <printf>
    printf("Empty string: %s\n", "");
    800007ac:	00000597          	auipc	a1,0x0
    800007b0:	3c458593          	add	a1,a1,964 # 80000b70 <test_printf_edge_cases+0x418>
    800007b4:	00000517          	auipc	a0,0x0
    800007b8:	3c450513          	add	a0,a0,964 # 80000b78 <test_printf_edge_cases+0x420>
    800007bc:	bbfff0ef          	jal	8000037a <printf>
    printf("Max hex: 0x%x\n", 0xFFFFFFFF);
    800007c0:	55fd                	li	a1,-1
    800007c2:	00000517          	auipc	a0,0x0
    800007c6:	3ce50513          	add	a0,a0,974 # 80000b90 <test_printf_edge_cases+0x438>
    800007ca:	bb1ff0ef          	jal	8000037a <printf>
    800007ce:	0001                	nop
    800007d0:	60a2                	ld	ra,8(sp)
    800007d2:	6402                	ld	s0,0(sp)
    800007d4:	0141                	add	sp,sp,16
    800007d6:	8082                	ret
